package com.wlf.admin.system.service;

import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wlf.admin.system.domain.ScheduleJob;
import com.wlf.admin.system.mapper.ScheduleJobMapper;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class ScheduleJobService extends ServiceImpl<ScheduleJobMapper, ScheduleJob> {
    /**
     * 获取spring容器里的beanName
     *
     * @param key 关键字，为空返回所有
     * @return beanName集合
     */
    public List<String> getBeanNameList(String key) {
        List<String> list = Arrays.asList(SpringUtil.getApplicationContext().getBeanDefinitionNames());
        if (key == null || key.isEmpty()) {
            return list;
        }
        return list.stream().filter(i -> i.contains(key)).collect(Collectors.toList());
    }
}
